package com.xiaoq.matrix.toutiao.util;

import weibo4j.org.json.JSONException;
import weibo4j.org.json.JSONObject;

public class TouTiaoException extends Exception {
	
	private int statusCode = -1;
    private int errorCode = -1;
    private String request;
    private String error;
    private static final long serialVersionUID = -2623309261327598087L;

    public TouTiaoException(String msg) {
        super(msg);
    }

    public TouTiaoException(Exception cause) {
        super(cause);
    }
    
    public TouTiaoException(String msg , int statusCode) throws JSONException {
    	super(msg);
    	this.statusCode = statusCode;
    }

    public TouTiaoException(String msg , JSONObject json, int statusCode) throws JSONException {
        super(msg + "\n error:" + json.getString("error") +" error_code:" + json.getInt("error_code") + json.getString("request"));
        this.statusCode = statusCode;
        this.errorCode = json.getInt("error_code");
        this.error = json.getString("error");
        this.request = json.getString("request");

    }

    public TouTiaoException(String msg, Exception cause) {
        super(msg, cause);
    }

    public TouTiaoException(String msg, Exception cause, int statusCode) {
        super(msg, cause);
        this.statusCode = statusCode;

    }

    public int getStatusCode() {
        return this.statusCode;
    }

	public int getErrorCode() {
		return errorCode;
	}

	public String getRequest() {
		return request;
	}

	public String getError() {
		return error;
	}

}
